Contents
  1. 1. Introduction
  2. 2. 问题描述
  3. 3. 解决关键
  4. 4. OVER

Introduction

申明一下》也许是我太弱了,居然不知道这种神奇。

问题描述

一般调用第三方登陆(例如这几天整的人头大的百度三方登陆)的接口时,都会遇到一个叫做redirect_url的参数,它往往是线上系统的域名下的某个地址,这样不能让回调地址转向本地,不利于本地测试。

解决关键

windows系统的hosts文件中可以设置让某个特定的域名和本机ip对应。hosts路径:C:\Windows\System32\drivers\etc

hosts内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 www.jiahuanle.net
# ::1 localhost

只需把

1
# 127.0.0.1       www.jiahuanle.net

前面的#号去掉,保存,就可以使其生效。

接下来,就可以happy的进行本地测试了!!!!

OVER

Contents
  1. 1. Introduction
  2. 2. 问题描述
  3. 3. 解决关键
  4. 4. OVER